package com.example.studentsystem;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import com.example.studentsystem.bean.UserBean;
import com.example.studentsystem.dao.MyDao;

import java.util.List;

public class Adapter2 extends BaseAdapter {
    ListView lv;
    Context context;
    List<UserBean> student;


    public Adapter2(Context context, List<UserBean> student,ListView lv) {
        this.context = context;
        this.student = student;
        this.lv = lv;

    }


    @Override
    public int getCount() {
        return student.size();
    }

    @Override
    public Object getItem(int i) {
        return student.get(i);
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        if(view == null)
            view = View.inflate(context,R.layout.adapter2,null);
        TextView id = view.findViewById(R.id.id);
        TextView name = view.findViewById(R.id.name);
        TextView sex = view.findViewById(R.id.sex);
        TextView banji = view.findViewById(R.id.banji);
        id.setText(student.get(i).getId()+"");
        name.setText(student.get(i).getName());
        sex.setText(student.get(i).getSex());
        banji.setText(student.get(i).getBanji());
        return view;
    }
}